<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="com.shxt.hotel.background.User"
         import="java.util.Map"
         import="java.util.List"
         import="com.shxt.hotel.background.Staff"
%>
<%
    Staff staff = new Staff();
    
    if(session.getAttribute("staff_id") == null){
        response.sendRedirect("./login.jsp");
    }else{
        // get current Staff
        request.setCharacterEncoding("UTF-8");
        int staff_id = (int)session.getAttribute("staff_id");
        
        Map<String, Object> currentStaff = staff.getStaffInfo(staff_id).get(0);
        User userManager = new User();
%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="../Public/img/favicon.html">

    <title>Basic Table</title>

    <!-- Bootstrap core CSS -->
    <link href="../Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="../Public/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="../Public/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="../Public/css/style.css" rel="stylesheet">
    <link href="../Public/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="../Public/js/html5shiv.js"></script>
      <script src="../Public/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

    <section id="container" class="">
        <!--header start-->
        <jsp:include page="./Public/header.jsp" flush="true"/>
        <!--header end-->
        <!--sidebar start-->
        <jsp:include page="./Public/sidebar.jsp" flush="true"/>
        <!--sidebar end-->
        <!--main content start-->
        <section id="main-content">
            <section class="wrapper">
                <!-- page start-->
                
                <div class="row">
                     <div class="col-lg-10">
                        <section class="panel panel-primary">
                            <header class="panel-heading">
                                User Info
                            </header>
                            <table class="table table-striped border-top" id="sample_1">
                            <thead>
                                    <tr>
                                        <th><i class="icon-bullhorn"></i> ID</th>
                                        <th class="hidden-phone"><i class="icon-question-sign"></i> User Name</th>
                                        <th><i class="icon-bookmark"></i> ID Card</th>
                                        <th><i class=" icon-edit"></i> Phone</th>
                                        <th>Permission</th>
                                        <th>Create Date</th>
                                        <th>BlackList</th>
                                        <th>Operation</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <%
                                        List<Map<String, Object>> userList = userManager.getUserList();
                                        for(Map<String, Object> user : userList){
                                                                                        
                                    %>
                                    <tr>
                                        <td><%=user.get("id") %></td>
                                        <td><%=user.get("username") %></td>
                                        <td><%=user.get("id_card") %></td>
                                        <td><%=user.get("phone") %></td>
                                        <td><%=user.get("user_permission") %></td>
                                        <td><%=user.get("create_date") %></td>
                                        <td style="color: red">
                                            <span class='<%=(Boolean)user.get("black_list") ? "icon-ban-circle" : "" %>' ></span>
                                        </td>
                                        <%
                                            Boolean is_black = (Boolean)user.get("black_list");
                                        %>
                                        <td>
                                            <%
                                                if(!is_black){
                                                    
                                            %>
                                                <a href='./background/user_blacklist_do.jsp?uid=<%=user.get("id") %>'>
                                                    <button type="button" class="btn btn-danger btn-xs">Pull to Black</button>
                                                </a>
                                            <%
                                                }else{
                                                    
                                            %>
                                                <a href='./background/user_cancel_blacklist_do.jsp?uid=<%=user.get("id") %>'>
                                                    <button type="button" class="btn btn-info btn-xs">Pull to Normal</button>
                                                </a>
                                            <%
                                                }
                                            %>
                                        </td>
                                    </tr>
                                    <%
                                        }
                                    %>
                                </tbody>
                            </table>
                        </section>
                    </div>
                </div>
                <!-- page end-->
            </section>
        </section>
        <!--main content end-->
    </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="../Public/js/jquery.js"></script>
    <script src="../Public/js/bootstrap.min.js"></script>
    <script src="../Public/js/jquery.scrollTo.min.js"></script>
    <script src="../Public/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Public/assets/data-tables/jquery.dataTables.js"></script>
    <script type="text/javascript" src="../Public/assets/data-tables/DT_bootstrap.js"></script>


    <!--common script for all pages-->
    <script src="../Public/js/common-scripts.js"></script>

    <!--script for this page only-->
    <script src="../Public/js/dynamic-table.js"></script>
    <script>
        $("#Hotel_User").addClass("active");
        $("#user_overview").addClass("active");
    </script>

</body>

</html>
<%
    }
%>